package com.example.kafka.controller;

import com.example.kafka.service.ProducerLeakService;
import com.example.kafka.service.ProducerLeakUtil4;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用例1 Controller
 */
@RestController
public class ProducerLeakController {
    @Autowired
    private ProducerLeakService producerLeakService;

    @PostMapping("/send1")
    public String sendMsg(@RequestBody String msg) {
        producerLeakService.send1(msg);
        return "ok";
    }

    @PostMapping("/batchSend2")
    public String batchSend(@RequestBody List<String> msgs) {
        producerLeakService.batchSend(msgs);
        return "ok";
    }

    @PostMapping("/send3")
    public String send3(@RequestBody String msg) {
        producerLeakService.send3(msg);
        return "ok";
    }

    @PostMapping("/send4")
    public String send4(@RequestBody String msg) {
        ProducerLeakUtil4.send(msg);
        return "ok";
    }

    @PostMapping("/send5")
    public String send(@RequestParam String topic, @RequestBody String msg) {
        producerLeakService.send5(topic, msg);
        return "ok";
    }
}
